<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <ul id="address">
        <li>武汉</li>
        <li>深圳</li>
        <li>北京</li>
        <li>上海</li>
    </ul>
    <ul id="city">
        <li>1</li>
        <li>2</li>
        <li>3</li>
        <li>4</li>
    </ul>
    <script>
        var city = document.getElementById('city')
        var liArr = city.getElementsByTagName('li');
        for (const item of liArr) {
            console.log(item.innerHTML);
        }

        var address = document.getElementById('address')
        var childs = address.childNodes; //获取子节点：标签间的空白会当成文本节点
        for (const item of childs) {
            console.log(item);
        }
        var childs2 = address.children; //获取子元素： 
        for (const item of childs2) {
            console.log(item.innerHTML);
        }

        console.log(address.firstChild); // 获取当前元素的第一个节点(包括空白文本节点)
        console.log(address.lastChild);
    </script>
</body>

</html>